﻿using M_Purchase.Api.Appliction.Command.AllocateCommand;
using M_Purchase.Domain;
using M_Purchase.Repository.PurchaseInterface;
using MediatR;

namespace M_Purchase.Api.Appliction.CommandHandlers.AllocateCommandHandler
{
    /// <summary>
    /// 反填充调拨命令处理器
    /// </summary>
    public class ReverseFillingAllocateCommandHandler : IRequestHandler<ReverseFillingAllocateCommand, Allocate>
    {
        /// <summary>
        /// 调拨仓储接口
        /// </summary>
        protected readonly IAllocateRepository allocateRepository;

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="allocateRepository">调拨仓储接口</param>
        public ReverseFillingAllocateCommandHandler(IAllocateRepository allocateRepository)
        {
            this.allocateRepository = allocateRepository;
        }
        
        /// <summary>
        /// 处理反填充调拨命令
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task<Allocate> Handle(ReverseFillingAllocateCommand request, CancellationToken cancellationToken)
        {
            return await allocateRepository.GetModelsAsync(request.AllocateId);
        }
    }
}
